
package ch.hearc.coursJava.examen.dessin;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;

import javax.swing.JFrame;

import ch.hearc.coursJava.GUI.j2D.tools.JPanelDessin_A;


/**
 *
 * @author raphael.capocasa
 *
 */
public class JPanelCentre extends JPanelDessin_A implements Runnable
	{
	/**
     * 
     */
    private static final long serialVersionUID = 1984217383851086072L;
    /*------------------------------------------------------------------*\
	|*							Constructeurs							*|
	\*------------------------------------------------------------------*/
	public JPanelCentre(JFrame frame)
		{
		this.colorBackground = Color.WHITE;
		this.colorCercle = Color.BLUE;
		this.setBackground(colorBackground);
		this.frame = frame;
		this.cercle = new Ellipse2D.Double(0, 200, 40, 40);
		alpha = 0;
		dAlpha = 0.0000001;
		}

	/*------------------------------------------------------------------*\
	|*							Methodes Public							*|
	\*------------------------------------------------------------------*/
	@Override
	protected void dessiner(Graphics2D g2d)
		{
		g2d.translate(this.getWidth() / 2, this.getHeight() / 2);
		g2d.rotate(alpha);
		g2d.setColor(this.colorCercle);
		g2d.fill(cercle);
		g2d.draw(cercle);
		}

	@Override
	public void run()
		{
		while(true)
			{
			incrementAlpha();
			this.repaint();
			}
		}

	public void incrementAlpha()
		{
		this.alpha -= dAlpha;
		}

	public void plusAlpha()
		{
		this.dAlpha += 0.0000005;
		}

	public void moinsAlpha()
		{
		this.dAlpha -= 0.0000005;
		}

	/*------------------------------*\
	|*				Set				*|
	\*------------------------------*/
	public void setdAlpha(double dAlpha)
		{
		this.dAlpha = dAlpha;
		}

	public void setColorBackground(Color colorBackground)
		{
		this.colorBackground = colorBackground;
		}

	public void setColorCercle(Color colorCercle)
		{
		this.colorCercle = colorCercle;
		}
	/*------------------------------*\
	|*				Get				*|
	\*------------------------------*/
	public Color getColorCercle()
		{
		return this.colorCercle;
		}

	public Color getColorBackground()
		{
		return this.colorBackground;
		}

	public double getdAlpha()
		{
		return this.dAlpha;
		}

	/*------------------------------------------------------------------*\
	|*							Attributs Private						*|
	\*------------------------------------------------------------------*/
	//input
	@SuppressWarnings("unused")
	private JFrame frame;

	//tools
	private Ellipse2D cercle;
	private double alpha;
	private double dAlpha;
	private Color colorBackground;
	private Color colorCercle;

	}

